package study.day5.t1;

public class Car {
    //属性
    //品牌
    String name;
    //型号
    String model;
    //生产年份
    int year;
    //里程数
    private int mile;

    //两个构造方法
    public Car(){

    }
    //带有三个参数的构造方法
    public Car(String name, String model, int year) {
        this.name = name;
        this.model = model;
        this.year = year;
    }

    public int getMile() {
        return mile;
    }

    public void setMile(int mile) {
        if(mile<0){
            mile=0;
        }else {
            this.mile = mile;
        }
    }

    public void show(){
        System.out.println("汽车品牌是："+name+"，型号为："+model+"，生产日期："+year+"，行驶里程是"+mile);
    }
}
